/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package load.education;

import core.InPort;
import core.OutPort;
import core.StdNode;
import java.awt.Color;

/**
 *
 * @author Ben
 */
public class Colors extends StdNode{
    private InPort rgb_red = new InPort(Integer.class);
    private InPort rgb_green = new InPort(Integer.class);
    private InPort rgb_blue = new InPort(Integer.class);
    private OutPort rgb = new OutPort(Color.class){
        @Override
        public Object getValueInternal() {
                return  new Color((Integer)rgb_red.getValue(), (Integer)rgb_green.getValue(),
                                   (Integer)rgb_blue.getValue());
        }
    };

    public Colors() {
        this.autoPutPorts();
        final Color[] COLORS = {Color.RED, Color.ORANGE,Color.YELLOW,Color.GREEN,
                          Color.BLUE,Color.MAGENTA, Color.PINK, new Color(150,75,0),
                          Color.BLACK, Color.WHITE, Color.GRAY};
        final String[] NAMES = {"red","orange","yellow","green","blue","magenta",
                                "pink","brown", "black","white","gray"};
        for(int i = 0; i< COLORS.length; i++){
            final Color c = COLORS[i];
            OutPort res = new OutPort(Color.class)
            {
                    @Override
                    public Object getValueInternal() {
                            return  c;
                    }
            };
            this.putPort(NAMES[i], res);
        }
    }
}
